const Service = require('egg').Service;

class loginService extends Service{

    async adminByNoAndPwd(admininfo){
        // console.log('1111111',admininfo);
        const sql = 'select username,password from admin where username=? and password=?';
        let r = await this.ctx.app.mysql.query(sql,[admininfo.username,admininfo.password]);
        console.log('adminByNoAndPwd',r);
        return r;
    }

    async userByNoAndPwd(userinfo){
        const sql = 'select username,password from user where username=? and password=?';
        let r = await this.ctx.app.mysql.query(sql,[userinfo.username,userinfo.password]);
        return r;
      }

      async adminregister(admininfo){
        const sql = `INSERT INTO admin (username,password,creattime) VALUES ('${admininfo.username}', '${admininfo.password}', now())`
        const res = await this.ctx.app.mysql.query(sql);
        // console.log('adminregister',res);
        return res;
    }
}
module.exports = loginService;